import React, { Component } from 'react'
import { BrowserRouter as Router, Route, Redirect } from 'react-router-dom'

// 导入首页和城市选择两个组件
import Home from './pages/Home'
import CityList from './pages/CityList'
import Map from './pages/Map'

export default class App extends Component {
  render() {
    return (
      <Router>
        <div className="app">
          {/* 默认路由匹配时，跳转到/home实现路由重定向到首页 */}
          <Route path="/" exact render={() => <Redirect to="/home" />}></Route>
          {/* 配置路由 */}
          {/* Home组件是父路由得内容 */}
          <Route path="/home" component={Home}></Route>
          <Route path="/citylist" component={CityList}></Route>
          <Route path='/map' component={Map}></Route>
        </div>
      </Router>
    );
  }
}
